Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(storage): Instrument existing metadata ops with storage trace package #11107

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

cojenco
Copy link
Contributor

@cojenco cojenco commented Nov 8, 2024

Update: supersedes #11051

  • Adds a development flag GO_STORAGE_DEV_OTEL_TRACING that will be removed upon experimental feature launch
  • Replaces existing metadata ops instrumentation with storage trace package (tracking sheet)
  • Adds emulated trace tests

Copy link

google-cla bot commented Nov 8, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Nov 8, 2024
@cojenco cojenco marked this pull request as ready for review November 8, 2024 23:11
@cojenco cojenco requested review from a team as code owners November 8, 2024 23:11
storage/acl.go Outdated Show resolved Hide resolved
@cojenco
Copy link
Contributor Author

cojenco commented Nov 12, 2024

@BrennaEpp could you PTAL and help check the CLA, thanks!

Copy link
Contributor

@tritone tritone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start on this!

@@ -91,8 +90,8 @@ func (a *ACLHandle) Delete(ctx context.Context, entity ACLEntity) (err error) {

// Set sets the role for the given entity.
func (a *ACLHandle) Set(ctx context.Context, entity ACLEntity, role ACLRole) (err error) {
ctx = trace.StartSpan(ctx, "cloud.google.com/go/storage.ACL.Set")
defer func() { trace.EndSpan(ctx, err) }()
ctx, _ = startSpan(ctx, "storage.ACL.Set")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it looks like we're dropping the actual returned Span. I assume we will use this later if we want to start adding more context pieces?

Also, does it make sense to have a separate endSpan method vs. calling Span.End directly on the span that was returned from startSpan? I recognize that you are basically just replicating the internal package pattern currently...

e.Reset()
}

func TestTraceSpansEmulated(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this to client_test.go (where we have other emulator tests currently)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are grouping by emulator tests I'd suggest renaming the file where we keep them

}

skippedTraceMethods := []string{"storage.Bucket.AddNotification", "storage.Bucket.Notifications", "storage.Bucket.DeleteNotification"}
for spanName, fn := range traceMethods {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this bespoke stuff shouldn't be necessary if you leverage the multi-transport harness that's already available in client_test?

// traceMethods are library methods that have trace instrumentation. This is a map whose keys are
// a string describing the spanName (e.g. storage.Bucket.Attrs) and values are functions which
// wrap library methods that implement the API calls.
var traceMethods = map[string]traceFunc{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could probably just move this in-line to the test (making it a table driven test)? It is a little awkward to read separately.

storage/trace.go Outdated
Comment on lines 51 to 56
if !isOTelTracingDevEnabled() {
ctx = internalTrace.StartSpan(ctx, name)
return ctx, nil
}
opts = append(opts, getCommonTraceOptions()...)
ctx, span := tracer().Start(ctx, name, opts...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, we are leaving out cloud.google.com/go/ from the trace name?

I'd suggest at least adding it back to the internalTrace implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants